﻿
$(function () {
    //初始化列表信息
    init();
});

//初始化列表信息
function init(queryData) {
    $('#list').datagrid({
        title: '员工档案',
        idField: 'EmployeeID',
        fitColumns: 'true',
        autoRowHeight: true,
        nowrap: true,
        striped: true,
        pagination: true,
        url: 'EmployeeStaff/GetList',
        columns: [[
			{ field: 'ck', checkbox: true },
			{ field: 'EmployeeID', title: 'ID', hidden: true},
			{ field: 'Name', title: '姓名', width: 180},
			{ field: 'Sex', title: '0-男；1-女', width: 180},
			{ field: 'Nation', title: '民族', width: 180},
			{ field: 'EntryDateTime', title: '入职时间', width: 180},
			{ field: 'Age', title: '年龄', width: 180},
			{ field: 'Birthday', title: '出生日期', width: 180},
			{ field: 'Photo', title: '照片', width: 180},
			{ field: 'IDcardNumber', title: '身份证号码', width: 180},
			{ field: 'Politicallandscape', title: '政治面貌', width: 180},
			{ field: 'IsMarried', title: '婚姻状况', width: 180},
			{ field: 'GraduateSchool', title: '毕业院校', width: 180},
			{ field: 'EducationalType', title: '学历', width: 180},
			{ field: 'Professional', title: '专业', width: 180},
			{ field: 'Accountlocation', title: '户口所在地', width: 180},
			{ field: 'Hometown', title: '籍贯', width: 180},
			{ field: 'Urbanhukou', title: '城镇户口', width: 180},
			{ field: 'LiveAdress', title: '居住地址', width: 180},
			{ field: 'phone', title: '联系电话', width: 180},
			{ field: 'Post', title: '邮编', width: 180},
			{ field: 'Department', title: '所属部门', width: 180},
			{ field: 'JobTitle', title: '职务', width: 180},
			{ field: 'PositiveTime', title: '转正时间', width: 180},
			{ field: 'ContractExpiration', title: '合同到期时间', width: 180},
			{ field: 'RenewedTime', title: '续签时间', width: 180},
			{ field: 'IsAdjustFile', title: '0-否；1-是；
   如果没有调档，填写档案所在地', width: 180},
			{ field: 'FileLocation', title: '档案所在地', width: 180},
			{ field: 'employType', title: '0-招聘；1-推荐；', width: 180},
			{ field: 'TrialSalary', title: '转正前薪资', width: 180},
			{ field: 'RelationPersonal', title: '紧急联系人', width: 180},
			{ field: 'RelativePhone', title: '紧急联系方式', width: 180},
			{ field: 'Salary', title: '转正后薪资', width: 180},
			{ field: 'EductionHistory', title: '教育经历', width: 180},
			{ field: 'WorkHistory', title: '工作经历', width: 180},
			{ field: 'FamilayInfo', title: '家庭情况', width: 180},
			{ field: 'SkillInfo', title: '特长', width: 180},
			{ field: 'HaveRelative', title: '公司是否有亲属', width: 180},
			{ field: 'RrewardHistory', title: '奖惩记录', width: 180},
			{ field: 'Remark', title: '备注', width: 180},
		
        ]],
    });
}

//弹出增加窗口
function add() {
    $('#dlg').dialog('open').dialog('setTitle', '增加');
    $('#fm').form('clear');
    url = '/EmployeeStaff/Create';
}

//弹出修改窗口
function edit() {
    var row = $('#list').datagrid('getSelected');
    if (row) {
        $('#dlg').dialog('open').dialog('setTitle', '修改');
        $('#fm').form('load', row);
        url = '/EmployeeStaff/Edit';
    }
}

//保存数据
function save() {
    $('#fm').form('submit', {
        url: url,
        onSubmit: function () {
            return $(this).form('validate');
        },
        success: function (result) {
            if (result == 'OK') {
                $('#dlg').dialog('close');      // close the dialog  
                $('#list').datagrid('reload');    // reload the user data  
            } else {
                $.messager.show({
                    title: 'Error',
                    msg: result
                });
            }
        }
    });
}

//删除
function del() {
    var rows = $('#list').datagrid('getSelected');
    if (rows) {
        $.messager.confirm(delDlgTitle, delDlgMsg, function (r) {
            if (r) {
                $.post('/EmployeeStaff/Delete', { id: rows.EmployeeID },
                    function (result) {
                        if (result == 'OK') {
                            $("#list").datagrid('clearSelections');
                            $('#list').datagrid('reload');    // reload the user data  
                        } else {
                            $.messager.show({   // show error message  
                                title: 'Error',
                                msg: result
                            });
                        }
                    });
            }
        });
    }
}